/***************************************************************************
 *            object_3d.h
 *
 *  Mon Aug 25 17:40:40 2008
 *  Copyright  2008  Tiago Falcão
 *  <tiago@tiagofalcao.com>
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#ifndef OBJECT_3D_H
#define OBJECT_3D_H

#include "points.h"
#include "matrix.h"
#include <GL/gl.h>
#include <GL/glut.h>

#define OBJ3D_MODE_DEFAULT 0x00
#define OBJ3D_MODE_SELECTED 0x01

typedef struct color{
float r,g,b,a;
} color_t;

typedef struct object_3d{
	unsigned int mode;					// Indica o modo de visualizacao
	color_t color;						// Cor do Objeto
	
	GLfloat * matrix;					// Matriz de Transformacao,modelo OpenGL
	
	GLfloat ambient[4];					// Reflexao da Luz Ambiente
	GLfloat diffuse[4];					// Reflexao da Luz Difusa
	GLfloat specular[4];				// Reflexao da Luz Especular
	GLfloat shininess;					// Concentracao da Reflexao
	GLfloat emission[4];				// Reflexao da Luz Emissiva
	
	void * object;						// Dados do Objeto
	void (*display)(void *,unsigned int);// Funcao de Desenho do Objeto
	void (*object_delete)(void *);		 // Funcao de Delete

} object3d;

// Cria Objeto 3D
object3d * obj3d_create(void (*display)(void *,unsigned int), void * object,void (*object_delete)(void *));

//Libera Objeto 3D
void obj3d_delete(object3d * obj);

// Desenha Objeto 3D
void obj3d_display(object3d * obj);

//Translacao em X
void obj3d_trans_x(object3d * obj,short int sign);
//Translacao em Y
void obj3d_trans_y(object3d * obj,short int sign);
//Translacao em Z
void obj3d_trans_z(object3d * obj,short int sign);

//Rotacao no eixo X
void obj3d_rot_x(object3d * obj,short int sign);
//Rotacao no eixo Y
void obj3d_rot_y(object3d * obj,short int sign);
//Rotacao no eixo Z
void obj3d_rot_z(object3d * obj,short int sign);

//Tamanho
void obj3d_size(object3d * obj,short int sign);

//Escala em X
void obj3d_scale_x(object3d * obj,short int sign);
//Escala em Y
void obj3d_scale_y(object3d * obj,short int sign);
//Escala em Z
void obj3d_scale_z(object3d * obj,short int sign);

//Seta Cor do Objeto
void obj3d_set_color(object3d * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Ambiente
void obj3d_set_ambient(object3d * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Difusa
void obj3d_set_diffuse(object3d * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Especular
void obj3d_set_specular(object3d * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Emissao
void obj3d_set_emission(object3d * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Brilho
void obj3d_set_shininess(object3d * obj,GLfloat shininess);

#endif /* OBJECT_3D_H */

